import store from "../../utils/localstorage";

const state = {
  // token信息
  token: store.get("token") || "",
  cancelTokens: [], // 待取消的请求集合,
  routerPath: store.get("routerPath") || "",
  userInfo:'张国泷',
  loginDialogStatus: false
};
const getters = {
  loginDgStatus: (state) => state.loginDialogStatus
}
const mutations = {
  set_token(state, data = "") {
    state.token = data;
    store.set("token", data);
  },
  set_routerPath(state, data = "") {
    state.routerPath = data;
    store.set("routerPath", data);
  },
  set_loginDialogStatus(state, status) {
    state.loginDialogStatus = status
  }
};
const actions = {
  set_token({ commit }, data) {
    return new Promise((resolve) => {
      commit("set_token", data);
      resolve && resolve(data);
    });
  },
  set_routerPath({ commit }, data) {
    return new Promise((resolve) => {
      commit("set_routerPath", data);
      resolve && resolve(data);
    });
  },
  set_loginDialogStatus({ commit }, data) {
    return new Promise((resolve) => {
      commit("set_loginDialogStatus", data);
      resolve && resolve(data);
    });
  },
};
export default {
  state,
  mutations,
  actions,
  getters
};
